﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Toolkit {
  public static class DateTimeTools {

    /// <summary>
    /// Fixes the timeformat to a short timeformat (hh:mm).
    /// </summary>
    /// <param name="time">The time.</param>
    /// <returns></returns>
    public static string FixShortTimeFormat( string time ) {

      return "";
    }


    public static class Convert {

      public static TimeSpan ToTimeSpan( string time ) {
        TimeSpan result = TimeSpan.Zero;
        if ( string.IsNullOrEmpty( time ) ) return result;

        Regex regex = new Regex( "^([0-1][0-9]|[2][0-3]):([0-5][0-9])$" );
        if ( !regex.IsMatch( time ) ) return result;

        TimeSpan.TryParse( time, out result );

        return result;
      }

    }

  }
}
